package main

import (
	"context"
	"database/sql"
	"github.com/heroiclabs/nakama-common/runtime"
	"nakama_poker/poker"
	"nakama_poker/rpc"
)

func InitModule(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, initializer runtime.Initializer) error {
	// Register the RPC function.
	if err := initializer.RegisterRpc("CreatePokerGame", rpc.CreatePokerGame); err != nil {
		logger.Error("[RegisterRpc] Unable to register: %v", err)
		return err
	}

	if err := initializer.RegisterRpc("GetPokerGame", rpc.GetPokerGame); err != nil {
		logger.Error("[RegisterRpc] Unable to register: %v", err)
		return err
	}

	if err := initializer.RegisterMatch("Poker", poker.NewPokerMatch); err != nil {
		logger.Error("[RegisterMatch] Unable to register: %v", err)
		return err
	}
	return nil
}
